﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class PackageSNChange : BaseRepository_DT<PackageSNChangeInfo>, IPackageSNChange
    {
        #region 静态变量定义部分
        private const string PARM_PACKAGESNCHANGE_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_PACKAGESNCHANGE_OLDPACKAGEPRODUCTSN = "@OldPackageProductSN";
        private const string PARM_PACKAGESNCHANGE_RECORDTIME = "@RecordTime";
        private const string PARM_PACKAGESNCHANGE_USERID = "@UserID";
        #endregion             


        #region 检索数据部分
        public PackageSNChangeInfo LoadEntity<T1>(T1 packageSN)
        {
            return null;
        }

        public IList<PackageSNChangeInfo> LoadEntities()
        {
            return null;
        }

        public IList<PackageSNChangeInfo> GetPackageSNChangebySN(string packageSN)
        {
            SqlParameter parm = GetParameter();
            parm.Value = packageSN;
            return ExcuteSqlToGetEntities("PackageProductSNChangeLog_selectbySN", parm);
        }

        public IList<PackageSNChangeInfo> GetPackageSNChangebyDT(DateTime starttime, DateTime stoptime)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = starttime;
            parms[1].Value = stoptime;
            return ExcuteSqlToGetEntities("PackageProductSNChangeLog_selectbyDT", parms);
        }
        #endregion


        #region 重写基类部分
        public override PackageSNChangeInfo GetEntityRecord(SqlDataReader rdr)
        {
            PackageSNChangeInfo pro = new PackageSNChangeInfo{ PackageProductSN = rdr.GetValue(0).ToString(), OldPackageProductSN = rdr.GetValue(1).ToString(), RecordTime = rdr.GetDateTime(2), UserID = rdr.GetValue(3).ToString() };
            return pro;
        }

        public override PackageSNChangeInfo GetEntityRecord()
        {
            PackageSNChangeInfo pro = new PackageSNChangeInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "PackageProductSNChangeLog_Insert";
        }

        //public override string GetInsertsp()
        //{
        //    return null;
        //}

        //public override string GetInsertsp()
        //{
        //    return null;
        //}

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_PACKAGESNCHANGE_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 100);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_PACKAGESNCHANGE_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 100),
					new SqlParameter(PARM_PACKAGESNCHANGE_OLDPACKAGEPRODUCTSN, SqlDbType.NVarChar, 100),
                    new SqlParameter(PARM_PACKAGESNCHANGE_RECORDTIME, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_PACKAGESNCHANGE_USERID, SqlDbType.Char , 10),
                };
            return parms;
        }

        public override void SetParameters(PackageSNChangeInfo packageSNChange, params SqlParameter[] Parms)
        {
            Parms[0].Value = packageSNChange.PackageProductSN;
            Parms[1].Value = packageSNChange.OldPackageProductSN;
            Parms[2].Value = packageSNChange.RecordTime;
            Parms[3].Value = packageSNChange.UserID;
        }
        #endregion
    }
}
